<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
	<head>
		<title>河南全一安防</title>
		<Link Rel="SHORTCUT ICON" href="/admin/images/head_logo.png">
		<meta charset="utf-8" />
		<meta http-equiv="X-UA-Compatible" content="IE=8"/>
		<link rel="stylesheet" type="text/css" href="/admin/css/index.css"/>
		<script src="/admin/js/jquery.js" type="text/javascript" charset="utf-8"></script>
		<title>全一安防</title>
	</head>
	<body>
		<div class="logo">
			<img src="/admin/images/logo2.png">
		</div>
		<div class="left">
			<img src="/admin/images/left.png" id="left"/>
		</div>
		<div class="right">
			<div class="system">
				<h2>全一安防管理系统</h2>
				<form method="post ">
					{{csrf_field()}}
					<input type="text" id="sjh" name="account" placeholder="账号"/>
					<div class="sjh">
						
					</div>
					<input type="password" name="password" id="mm" placeholder="请输入密码"/>
					<div class="mm">
						
					</div>
					<input type="text" name="verify" id="yzm"  placeholder="验证码"/>
					<div class="yzm">
						<img src="/code" title="点击刷新" onclick="this.src=this.src+'?a=1'"/>
					</div>
					<div class="yzyzm">
						
					</div>
					<input type="button" id="denglu" name="" value="登	录"/>
				</form>
				<p><a href="/admin/reg">新用户，请注册</a></p>
				<p><a href="/admin/login/lost">忘记密码</a></p>
			</div>
		</div>
	</body>
</html>

<script>
	var cond2 = false;
	var cond3 = false;
	// 账户获得焦点事件
	$("input[name=account]").focus(function(){
		$(".sjh").html("");
	});
	// 密码获得焦点事件
	$("input[name=password]").focus(function(){
		$(".mm").html("");
	});
	// 验证码获得焦点事件
	$("input[name=verify]").focus(function(){
		$(".yzyzm").html("");
	});
	// 账号失去焦点事件
	$("input[name=account]").blur(function(){
		if($("input[name=account]").val() !=''){
			return cond2 = true;
		}else{
			$(".sjh").html("<font style='font-size:12px;color:#8b0000;'>*请入用户名</font>");
		}
	});
	$("input[name=password]").blur(function(){
		if($("input[name=password]").val()!=''){
			return cond3 = true;
		}else{
			$(".mm").html("<font style='font-size:12px;color:#8b0000;'>*请输入密码</font>");
		}
	});
	$("input[name=verify]").blur(function(){
		if($("input[name=verify]").val()==''){
			$(".yzyzm").html("<font style='font-size:12px;color:#8b0000;'>*请输入验证码</font>");
		}
	});
    //回车键登录	
    $("body").bind('keyup',function(event) {
        if(event.keyCode==13){
              if($("input[name=yzm]").val()!=''){
    		if(cond2&&cond3){
		        var account = $('#sjh').val();
		        var password = $('#mm').val();
		        var verify = $('#yzm').val();
		        //ajax请求
		        $.ajax({
	                type:'post',
	                url:'/admin/login/logaction',
	                async:false,
	                data:{
	                    "_token": $("input[name=_token]").val(),
	                    'account':account,
	                    'password':password,
	                    'verify':verify
	                },
	                dataType:'json',
	                success:function (data) {
	                    if(data.status == '-1' ||data.status == '-2'){
                            $(".sjh").html("<font style='font-size:12px;color:#8b0000;'>*你输入的账号或密码不正确</font>");
						}
                        if(data.status == '-3'){
                            $(".yzyzm").html("<font style='font-size:12px;color:#8b0000;'>*"+data.msg+"</font>");
                        }
                        if(data.status == '-4'){
                            $(".mm").html("<font style='font-size:12px;color:#8b0000;'>*"+data.msg+"</font>");
                        }
	                    if(data.status == '1'){
	                        location.href = '/';
	                    }
	                }
	            });
    		}
		}else{
			$(".yzyzm").html("<font style='font-size:12px;color:#8b0000;'>*请输入验证码</font>");
		};
        }
   	});
    //提交处理
    $('#denglu').click(function () {
    	if($("input[name=yzm]").val()!=''){
    		if(cond2&&cond3){
		        var account = $('#sjh').val();
		        var password = $('#mm').val();
		        var verify = $('#yzm').val();
		        //ajax请求
		        $.ajax({
	                type:'post',
	                url:'/admin/login/logaction',
	                async:false,
	                data:{
	                    "_token": $("input[name=_token]").val(),
	                    'account':account,
	                    'password':password,
	                    'verify':verify
	                },
	                dataType:'json',
	                success:function (data) {
                        if(data.status == '-1' ||data.status == '-2'){
                            $(".sjh").html("<font style='font-size:12px;color:#8b0000;'>*你输入的账号或密码不正确</font>");
                        }
                        if(data.status == '-3'){
                            $(".yzyzm").html("<font style='font-size:12px;color:#8b0000;'>*"+data.msg+"</font>");
                        }
                        if(data.status == '-4'){
                            $(".mm").html("<font style='font-size:12px;color:#8b0000;'>*"+data.msg+"</font>");
                        }
	                    if(data.status == '1'){
	                        location.href = '/'
	                    }
	                }
	            });
    		}
		}else{
			$(".yzyzm").html("<font style='font-size:12px;color:#8b0000;'>*请输入验证码</font>");
		}
	});
</script>
